export const formConfig = [
    {
        name: 'name',
        type: 'input',
        placeholder: '模型组名称',
    },
]

export const column = [
    {
        label: '模型组名称',
        name: 'name',
    },
    {
        label: '模型代码',
        name: 'm_code',
    },
    {
        label: '模型名称',
        name: 'm_name',
    },
    {
        title: '操作',
        name: 'action',
        width: '260',
        buttons: [],
    },
]

export const config = [
    {
        name: 'name',
        type: 'input',
        placeholder: '模型组名称',
        label: '模型组名称',
        required: true,
    },
    {
        name: 'm_code',
        type: 'cascader',
        placeholder: '选择模型',
        label: '选择模型',
        options: [],
        multiple: true,
        showAllLevels: true,
        checkStrictly: false,
        required: true,
    },
]

export const formatData = (data) => {
    const result = []
    data.forEach((item) => {
        if (item.m_type && item.m_d && item.m_d_code) {
            let modelType = result.find((item1) => item1.value === item.m_type)
            if (!modelType) {
                modelType = {
                    label: item.m_type,
                    value: item.m_type,
                    children: [],
                }
                result.push(modelType)
            }
            let troubleType = modelType.children.find((item2) => item2.value === item.m_d_code)
            if (!troubleType) {
                troubleType = {
                    label: item.m_d,
                    value: item.m_d_code,
                    children: [],
                }
                modelType.children.push(troubleType)
            }
            const warnCode = {
                label: `${item.m_desc} `,
                value: item,
            }
            troubleType.children.push(warnCode)
        }
    })
    return result
}

export const config1 = [
    {
        label: '选择模型',
        type: 'select',
        name: 'model',
        required: true,
        options: [],
    },
    {
        name: 'm_type',
        type: 'input',
        label: '模型类型',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_d',
        type: 'input',
        label: '模型大类',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_d_code',
        type: 'input',
        label: '模型大类编码',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_m',
        type: 'input',
        label: '模型小类',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_m_code',
        type: 'input',
        label: '模型小类编码',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_desc',
        type: 'input',
        label: '模型描述',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
    {
        name: 'm_version',
        type: 'input',
        label: '模型版本',
        required: true,
        group: '模型配置',
        disable: () => true,
    },
]
